﻿`3<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wfRegionalAgentList.aspx.cs" Inherits="msBsc.WebUi.ShpMana.wfRegionalAgentList" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>区域代理列表</title>
    <link href="/jqPlugin/jqTab/ui.tabs.css" rel="stylesheet" type="text/css" />

    <script src="/jqPlugin/jqTab/ui.tabs.js" type="text/javascript"></script>

    <link href="/jqPlugin/kindeditor/themes/default/default.css" type="text/css" rel="stylesheet" />
    <link href="/jqPlugin/SelectSimu/css/base.css" rel="stylesheet" />
    <script src='/??jqPlugin/kindeditor/kindeditor.js,jqPlugin/kindeditor/lang/zh_CN.js'
        type='text/javascript'></script>
    <style type="text/css">
        html, body {
            overflow: hidden;
            margin-left: 0px;
            margin-top: 0px;
            margin-right: 0px;
            margin-bottom: 0px;
        }

        .select .selectInput {
            width: 80px !important;
        }

        #outerInner, #province, #city {
            display: block;
            width: 80px !important;
            float: left;
            margin-right: 10px;
            z-index: 9999 !important;
        }
    </style>
    <script src="/jqPlugin/js/jBase.js"></script>
    <script src="/jqPlugin/js/jBPage.js"></script>
    <script src="/jqPlugin/js/laytpl.js"></script>
    <script src="/jqPlugin/SelectSimu/js/SelectSimu.js"></script>
    <!--end JS引用-->


</head>
<body>
    <form id="wfConstantHandle" method="post" runat="server">
        <asp:HiddenField ID="txtStatus" runat="server" Value="0" />
        <div style="width: 100%; text-align: left; margin: 0px 0px 0px 0px;">
            <div id="container2" style="width: 100%; margin-top: 3px; display: none;">
                <div id="fragment1">
                    <div id="divCondition" style="margin: 0px; border-style: solid; border-width: 1px; border-color: #C8D2E0;">
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td class="label" width="70px">姓名
                                </td>
                                <td align="right" width="110px">
                                    <asp:TextBox ID="txtRealName" runat="server" Width="110px" MaxLength="100"></asp:TextBox>
                                </td>
                                <td class="label" width="70px">联系电话
                                </td>
                                <td align="right" width="110px">
                                    <asp:TextBox ID="txtMobile" runat="server" Width="110px" MaxLength="100"></asp:TextBox>
                                </td>
                                <td class="label" width="70px">地区选择
                                </td>
                                <td width="280px">
                                    <div class="search">
                                        <select class="selArea" id="selCountry">
                                            <option value="0">请选择</option>
                                            <option value="DF6723BE-A25C-4F77-BB49-A1662D3E6F2A">中国</option>
                                            <option value="453370FE-8295-41EC-A41C-B6F650AD1B4C">亚洲</option>
                                            <option value="927D5F28-C4FB-46A9-940C-B07DF0A04018">北美洲</option>
                                            <option value="1FEAF456-7C76-41C8-A3D0-F9C12415A736">南美洲</option>
                                            <option value="4E2B4524-E9CB-4E20-9224-E58EB636D1C7">非洲</option>
                                            <option value="67FA6A8D-951C-4B53-AE1E-70DCB97E11DE">欧洲</option>
                                            <option value="0B772F3D-D8F8-42E3-9019-81FE6F772236">大洋洲</option>
                                        </select>&nbsp;&nbsp;
                                        <select class="selArea" id="selCity">
                                            <option value="0">请选择</option>
                                        </select>&nbsp;&nbsp;
                                        <xmp id="country_city_list" style="display: none">
                                <option value="0">请选择</option>
                                {{#for(var i=0,len=d.rows.length;i < len;i++){ }}
                                       <option value="{{d.rows[i].COUNTRY_CITY_ID}}">{{d.rows[i].COUNTRY_CITY_NME}}</option>
                                {{#} }}        
                            </xmp>
                                        <select class="selArea" id="selDestination">
                                            <option value="0">请选择</option>
                                        </select>
                                        <xmp id="city_des_list" style="display: none">
                               <option value="0">请选择</option>
                               {{#for(var i=0,len=d.rows.length;i < len;i++){ }}
                                <option value="{{d.rows[i].COUNTRY_CITY_ID}}">{{d.rows[i].COUNTRY_CITY_NME}}</option>
                               {{#} }}
                            </xmp>
                                    </div>
                                </td>
                                <td align="center">
                                    <input type="button" onclick="javascript: btnDo('mFinder'); return false;" value="查询(F)"
                                        id="btnFinder" accesskey="F" />
                                    <input type="button" onclick="javascript: viewItem('', 'add'); return false;" value="添加区域代理(A)"
                                        id="Button1" accesskey="E" />
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div id="bigbox2" style="margin: 0px; margin-top: 2px;">
                        <div id="gridbox1" style="border: 0px solid #cccccc; background-color: #f3f3f3; padding: 5px;">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>


    <script type="text/ecmascript">
        $(window).load(function () {

            //初始化步进式搜索框
            $('#container2').fadeIn("fast"); //初始化TAB页选择控件
            $('#container2 ul').tabs();
            mygrid1.render();
            mygrid1.readOnly = true;
            autogtResize("bigbox2", mygrid1);
            SetBtnEnable('btnEdit', 'btnSave,btnNotSave,btnConfirm,btnCancel');
        });

        function doTabChange(sStatus) {
            if (sStatus != $('#txtStatus').val()) {
                $('#txtStatus').val(sStatus); btnDo('mFinder');
            }
        };

        //视图 切换
        function viewItem(sid, reqType) {
            if (reqType == "md") {
                OpenDialog("/ShpMana/wfUpdateRegionalAgent.aspx?userid=" + sid, null, null, "修改");
            }
            else if (reqType == "add") {
                OpenDialog("/ShpMana/wfAddRegionalAgent.aspx", null, null, "添加区域代理");
            }
            else if (reqType == "sd") {
                window.parent.addTabPage("区域地接客管理", "/h_RegionalDjkList.htm?faccoutId=" + sid);
            }
            else if (reqType == "adjk") {
                OpenDialog("/h_AgentDjackManage.htm?agentid=" + sid, null, null, "添加地接客");

            }

        };

        //绑定 删除状态
        var clopCheckBox = { "True": "否", "False": "是" };
        function clrdCheckBox(value, record, columnObj, grid, colNo, rowNo) {
            var options = clopCheckBox;
            var ret = options[value];
            if (ret == null) {
                ret = value;
            }
            return ret;
        };

        //要自定义显示，比如链接等字段如下buynow,在renderer函数中返回要显示的HTML编码字符
        var colsOption = [


             { id: 'CUSTOMER_BASEINFO_NAME', header: "姓名", width: 150 },
            { id: 'CUSTOMER_BASEINFO_MOBILE', header: "手机号码", width: 150 },
            { id: 'CUSTOMER_BASEINFO_PHONE', header: "座机号码", width: 150 },
            { id: 'CUSTOMER_CREDENTIALS_NO', header: "身份证号码", width: 150 },

        { id: 'C_NAME', header: "国家", width: 130 },
        { id: 'P_NAME', header: "城市", width: 130 },
        { id: 'A_NAME', header: "目的地", width: 130 },
        { id: 'ACCOUNT_IS_DELETED', header: "是否启用", width: 100, renderer: clrdCheckBox },
        {
            id: 'IS_DELETED', header: "基本操作", width: 70, resizable: false, filterable: false, exportable: false, sortable: false, printable: false,
            renderer: function (value, record, columnObj, grid, colNo, rowNo) {
                var status = record.ACCOUNT_IS_DELETED == "False" ? 0 : 1;
                var html = "<a  href=\"javascript:void(0);return false;\" onclick=\"javascript:viewItem('" + record.CUSTOMER_REGISTER_ID + "','md');return false;\" target='_self'>修改</a>";
                html += " &nbsp&nbsp<a  href=\"javascript:void(0);return false;\" onclick=\"javascript:updateStatus('" + record.CUSTOMER_REGISTER_ID + "','" + record.CUSTOMER_BASEINFO_NAME + "'," + (status > 0 ? 0 : 1) + ");return false;\" >" + (status > 0 ? "启用" : "禁用") + "</a>";
                return html;

            }
        },
        {
            id: 'CUSTOMER_REGISTER_ID', header: "地接客操作", width: 100, resizable: false, filterable: false, exportable: false, sortable: false, printable: false,
            renderer: function (value, record, columnObj, grid, colNo, rowNo) {
                var html = "<a  href=\"javascript:void(0);return false;\" onclick=\"javascript:viewItem('" + record.CUSTOMER_REGISTER_ID + "','sd');return false;\" target='_self'>详情</a>";
                html += " &nbsp&nbsp<a  href=\"javascript:void(0);return false;\" onclick=\"javascript:viewItem('" + record.CUSTOMER_REGISTER_ID + "','adjk');return false;\" target='_self'>添加地接客</a>";
                return html;
            }
        }
        ];

        //以下为固定的代码
        var gridOption1 = getGtOp('myGrid1', colsOption, 'gridbox1', 'BANK_ID');
        var mygrid1 = new Sigma.Grid(gridOption1);

        //事件处理
        function btnDo(sEbtn) {
            GtGrid1Action = sEbtn;
            var opart = GetGtParam("myGrid1");
            if (sEbtn == "mFinder") {
                doFinderGt('myGrid1');
            }
            else if (sEbtn == "btnEdit") {
                opart.AddCell("sEditMode", "EDIT");
                ajaxComm(opart, null, null, 'divCondition'); //调用页面回调，并传入参数
            }
            else if (sEbtn == "btnSave") {
                doSaveGt('myGrid1');
            }
            else if (sEbtn == "btnConfirm" || sEbtn == "btnCancel") {
                var sidtem1 = GetGtSelectId('myGrid1');
                if (sidtem1) {
                    opart.AddCell("CHECK_ID", sidtem1);
                    ajaxComm(opart, null, null, 'divCondition'); //调用页面回调，并传入参数
                } else {
                    alert("请先选择记录！");
                }
            }
            else {
                ajaxComm(opart, null, null, 'divCondition'); //调用页面回调，并传入参数
            }
            GtGrid1Action = "";
        };

        //参数绑定
        function GetGtParam(jqGridID) {
            var _jsParam = new jsonRow();
            if (jqGridID == "myGrid1") {
                GetFormJson("divCondition", _jsParam);
                _jsParam.AddCell("PPAGE", "wfConstantHandle"); //这个地方是该页面的类名
                _jsParam.AddCell("gtGridID", "myGrid1");
                _jsParam.AddCell("sRadom", $("#sRadom").val());
                _jsParam.AddCell("txtRealName", $("#txtRealName").val());
                _jsParam.AddCell("txtMobile", $("#txtMobile").val());

                _jsParam.AddCell("countryId", $("#selCountry option:selected").val());
                _jsParam.AddCell("cityId", $("#selCity option:selected").val());
                _jsParam.AddCell("destinationId", $("#selDestination option:selected").val());

                _jsParam.AddCell("ACTION", GtGrid1Action);
                //这里可增加传入后台的参数
            }
            return _jsParam;
        };

        //是否启用
        function updateStatus(id, name, status) {
            if (!confirm("你确认要" + (status > 0 ? "启用" : "禁用") + "\t'" + name + "'\t区域代理")) {
                return;
            }
            var opart = new jsonRow();
            opart.AddCell("userid", id);
            opart.AddCell("status", status);
            opart.AddCell("ACTION", "upStatus");
            ajaxComm(opart);
        }
        //成功
        function success() {
            alert('修改成功');
            setTimeout(function () {
                location.href = "/h_RegionalAgentList.htm";
            }, 1000);
        }
        //注册 地区联动
        function SetAreaInfo() {
            $("#selCountry").change(function () {
                $("#selCity").html("<option value='0'>请选择</option>");
                $("#selDestination").html("<option value='0'>请选择</option>");
                var _opartParam = new jsonRow();
                _opartParam.AddCell("countryId", $("#selCountry").val());
                _opartParam.AddCell("cityId", $("#selCity").val());
                _opartParam.AddCell("ACTION", "changeArea");
                ajaxComm(_opartParam);
            });

            $("#selCity").change(function () {
                $("#selDestination").html("<option value='0'>请选择</option>");
                var _opartParam = new jsonRow();
                _opartParam.AddCell("cityId", $("#selCity").val());
                _opartParam.AddCell("ACTION", "changeArea");
                ajaxComm(_opartParam);
            });
        }
        SetAreaInfo();
    </script>
</body>
</html>
